﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace UI
{
    /// <summary>
    /// Summary description for ImageRequestHandler
    /// </summary>
    public class ImageRequestHandler : IHttpHandler, System.Web.SessionState.IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.Clear();

            if (context.Request.QueryString.Count != 0)
            {
                byte[] imageData = context.Session["SessionImage"] as byte[];

                if (imageData != null)
                {
                    context.Response.OutputStream.Write(imageData, 0, imageData.Length);
                    context.Response.ContentType = "image/JPEG";
                }
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}